package com.woniuxy.project115.kaer.mall.config;

import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;

@Configuration
public class RabbitMQConfig {
    //创建一个队列提交给springboot
    @Bean
    public Queue sendRegCodeQueue() {
        return new Queue("send_register_code");
    }

//    //创建一个带过期时间的消息队列用于延迟删除
//    @Bean
//    public Queue deleteCacheQueue() {
//        HashMap<String, Object> map = new HashMap<>();
//        //设置过期时间
//        map.put("x-message-ttl", 10 * 1000);
//        //设置死信交换机
//        map.put("x-dead-letter-exchange", "de1");
//        //设置死信路由key
//        map.put("x-dead-letter-routing-key", "delete_cache");
//        return new Queue("waiting_delete_cache_queue", true, false, false, map);
//    }

    @Bean
    public Queue waitingCheckOrderQueue() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("x-message-ttl", 1 * 60 * 1000);
        map.put("x-dead-letter-exchange", "de2");
        map.put("x-dead-letter-routing-key", "check_order");
        return new Queue("waiting_check_order_queue", true, false, false, map);
    }
    @Bean
    public Queue waitingCheckIsEvaluateQueue() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("x-message-ttl", 1* 60 * 1000);
        map.put("x-dead-letter-exchange", "de3");
        map.put("x-dead-letter-routing-key", "check_isEvaluate");
        return new Queue("waiting_check_isEvaluate_queue", true, false, false, map);
    }
}
